Skip to content

geotiff: support fsspec URIs in read_geotiff_dask (#1749)#1755

Open
brendancol wants to merge 1 commit into
mainfrom
issue-1749
Open

geotiff: support fsspec URIs in read_geotiff_dask (#1749)#1755
brendancol wants to merge 1 commit into
mainfrom
issue-1749

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

  • read_geotiff_dask failed on s3://, gs://, az://, memory:// and other fsspec URIs with FileNotFoundError. The eager path already handled cloud URIs via _read_to_array + _CloudSource, but the dask path's metadata-only step (_read_geo_info in xrspatial/geotiff/__init__.py) used a plain open(source, 'rb') call.
  • Per-chunk pixel reads in the dask graph were already cloud-aware (they go through _read_to_array which dispatches to _CloudSource), so only the upfront metadata read needed fixing.
  • Route fsspec URIs in _read_geo_info through _CloudSource.read_all(). The local-path mmap fast path is unchanged. The HTTP path (which uses _parse_cog_http_meta) is unchanged.

Closes #1749.

Test plan

  • New test_dask_path_fsspec_uri_1749 in TestCloudStorage writes a small TIFF, copies it into the fsspec memory:// filesystem, and verifies open_geotiff('memory:///...', chunks=4) returns a dask-backed DataArray whose values match both the eager read and the original array.
  • Full TestCloudStorage class still passes (6/6).
  • Wider xrspatial/geotiff/tests/ suite shows the same pre-existing failures as main (GPU/matplotlib unrelated to this change).

…1749)

read_geotiff_dask failed on s3://, gs://, az://, memory:// and other
fsspec URIs because the metadata-only step (_read_geo_info) used a
plain open(source, 'rb') call. The eager path already handled cloud
URIs via _read_to_array + _CloudSource, so the dask graph's per-chunk
pixel reads were already cloud-aware; only the upfront metadata read
broke.

Detect fsspec URIs in _read_geo_info and pull the file bytes via
_CloudSource.read_all(). Local-path mmap fast path is unchanged.
HTTP path is unchanged and continues to use _parse_cog_http_meta.

Closes #1749.
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 12, 2026
@brendancol brendancol requested a review from Copilot May 12, 2026 23:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes open_geotiff(..., chunks=...) / read_geotiff_dask failures for fsspec-backed URIs (e.g., s3://, gs://, az://, memory://) by making the upfront metadata read (_read_geo_info) cloud-aware, aligning dask reads with the existing eager read path.

Changes:

  • Route fsspec/cloud URIs in _read_geo_info through _CloudSource instead of open(..., 'rb').
  • Add a regression test that reads a GeoTIFF from memory:// using dask chunks and validates results against eager reads and the original array.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
xrspatial/geotiff/__init__.py Adds an fsspec URI branch in _read_geo_info to avoid local open() for cloud/memory schemes.
xrspatial/geotiff/tests/test_features.py Adds a regression test covering dask reads from an fsspec memory:// URI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +480 to +484
elif isinstance(source, str) and _is_fsspec_uri(source):
# fsspec URI (s3://, gs://, az://, memory://, ...): pull the
# whole file via _CloudSource for metadata parsing. Per-chunk
# pixel reads in the dask graph go through _read_to_array
# which opens its own _CloudSource, so this fetch is metadata-only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

geotiff: read_geotiff_dask does not support fsspec / cloud URIs

2 participants